#include "cppbaer.h"
#include <iostream>
#include <limits>
#include<cstring>
#include<ctime>

using namespace std;

class Box;

void printBook(struct Books book);
void printBook2(struct Books *book);

int testx(){
    cout << "type:\t\t" << "*************size**************" <<endl;
    cout << "bool:\t\t" << "所占字节数：" <<sizeof(bool);
    cout  << "\t最大值"  << (numeric_limits<bool>::max)();
    cout << "\t\t最小值" << (numeric_limits<bool>::min)();
}

void test14() {
    string str1 = "Hello";
    string str2 = "World";
    string str3;
    int len;

    str3 = str1;
    cout << "str3:"<< str3 << endl;

    str3 =  str1 + str2;
    cout << "str1 + str2 = " << str3 << endl;

    len = str3.size();
    cout<<"str3.size()"<<len<<endl;
}

void test15() {
    char str1[11] = "Hello";
    char str2[11] = "World";
    char str3[11];
    int len;

    strcpy(str3, str1);
    cout<<"strcpy(str3,str1)"<<str3<<endl;

    strcat(str1, str2);
    cout<<"strcat(str1,str2):"<<str1<<endl;

    len = strlen(str1);
    cout<<"strlen(str1)"<<len<<endl;
}

// 指针
void test16(){
    int var1;
    char var2[10];

    cout<<"var1 变量的地址：";
    cout<<&var1<<endl;

    cout<<"var2变量的地址";
    cout<<&var2<<endl;
}

void test17() {
    int var = 20;
    int *ip;

    ip = &var;

    cout<<"Value of var variable:";
    cout<<var<<endl;

    cout<<"Address stored in ip variable";
    cout<<ip<<endl;

    cout<<"Value of *ip variable:";
    cout<<*ip<<endl;
}


// 时间
void test20() {
    time_t now  = time(0);

    char* dt =  ctime(&now);
    cout<<"本地日期和时间"<<dt<<endl;

    tm *gmtm = gmtime(&now);
    dt = asctime(gmtm);
    cout<<"UTC 日期和时间"<<dt<<endl;
}

void test21() {
    time_t now = time(0);

    cout<<"1970到目前经过秒数"<<now<<endl;

    tm *ltm = localtime(&now);

    cout<<"年："<<1900+ltm->tm_year<<endl;
    cout<<"月："<<1+ltm->tm_mon<<endl;
    cout<<"日："<<1900+ltm->tm_mday<<endl;
    cout<<"时间："<<1900+ltm->tm_hour<<endl;

    cout<<ltm->tm_min<<":";
    cout<<ltm->tm_sec<<endl;
}

struct Books
{
    char title[50];
    char author[50];
    char subject[100];
    int book_id;
};

typedef  struct Book{
    char title[50];
    char author[50];
    char subject[100];
    int book_id;
} Book;

void test30(){
    Books book1;
    Books book2;

    strcpy(book1.title, "C++ Project");
    strcpy(book1.author, "Runnob");
    strcpy(book1.subject, "前端技术");
    book1.book_id = 123456;

    strcpy(book2.title, "C++ Project");
    strcpy(book2.author, "Runnob");
    strcpy(book2.subject, "前端技术");
    book2.book_id = 123456;

    cout<<"第一本书标题："<<book1.title<<endl;
    cout<<"第一本书作者："<<book1.author<<endl;
    cout<<"第一本书类目："<<book1.subject<<endl;
    cout<<"第一本书ID："<<book1.book_id<<endl;

    cout<<"\n\n"<<endl;

    cout<<"第一本书标题："<<book1.title<<endl;
    cout<<"第一本书作者："<<book1.author<<endl;
    cout<<"第一本书类目："<<book1.subject<<endl;
    cout<<"第一本书ID："<<book1.book_id<<endl;


    cout<<"\n=================\n"<<book1.book_id<<endl;
    printBook(book1);
    printBook(book2);
    cout<<"\n=================\n"<<book1.book_id<<endl;
    printBook2(&book1);
    printBook2(&book2);
}

void printBook(struct Books book){
    cout<<"第一本书标题："<<book.title<<endl;
    cout<<"第一本书作者："<<book.author<<endl;
    cout<<"第一本书类目："<<book.subject<<endl;
    cout<<"第一本书ID："<<book.book_id<<endl;
}

void printBook2(struct Books *book){
    cout<<"书标题："<<book->title<<endl;
    cout<<"书作者："<<book->author<<endl;
    cout<<"书类目："<<book->subject<<endl;
    cout<<"书ID："<<book->book_id<<endl;
}

void test40(){
    Box box1;
    Box box2;
    double volume = 0.0;

    box1.height = 5.0;
    box1.length = 6.0;
    box1.breadth = 7.0;

    box2.height = 10.0;
    box2.length = 12.0;
    box2.breadth = 13.0;

    volume = box1.height * box1.length  * box1.breadth;
    cout<<"box1的体积"<<volume<<endl;

    volume = box2.height * box2.length * box2.breadth;
    cout<<"box2的体积"<<volume<<endl;


}


void testx1() {

}

void testx2(){
    PrintData pd;

    pd.print(5);
    pd.print(500.265);
    pd.print("Hello C++");
}

void testx3() {
    Box box1;
    Box box2;
    Box box3;
    double volume = 0.0;

    box1.setLength(6.0);
    box1.setBreadth(7.0);
    box1.setHeight(5.0);

    box2.setLength(12.0);
    box2.setBreadth(13.0);
    box2.setHeight(10.0);

    volume = box1.getVolume();
    cout<<"Volume of box1:1"<<volume<<endl;

    volume = box2.getVolume();
    cout<<"Volumen of box2:"<<volume<<endl;

    box3 = box1+box2;
    volume = box3.getVolume();
    cout<<"Volume of box3"<<volume<<endl;
}


void testx4(){

}

